<template>
  <div class="form-subform-preview">
    <div class="form-preview-group">
      <label>
        {{ _displayName }}
        <span class="form-preview-notNull" v-if="field.isNull == 0">*</span>
      </label>
      <div class="form-preview-mock">
        <span class="form-type-text">{{subFormMark}}</span>
      </div>
    </div>

    <div class="form-subform-preview-content">
      <!-- start 关联显示字段 -->
      <div class="form-subform-preview-title">{{subFormPreviewTitle}}</div>
      <div class="form-preview">
        <div
          class="form-design-preview"
          v-for="item in productRelatedFields"
          :key="item.fieldName"
        >
          <div class="form-preview-group">{{ returnDisplayName(item) }}</div>
        </div>
      </div>
      <!-- end 关联显示字段 -->
    </div>
  </div>
</template>

<script>
import { previewProps } from '@src/component/form/components/props';
/* mixin */
import FormSubFormMixin from '@src/component/form/mixin/form.subForm';
import translate from '@src/component/form/mixin/translate.js'
import { transformI18n } from '@src/locales'


export default {
  name: 'form-relation-form-preview',
  mixins: [FormSubFormMixin, translate],
  props: previewProps,
  computed: {
    productRelatedFields: {
      get() {
        return this.subformFields || []
      },
      set(value) {
        this.$set(this.field, 'subFormFieldList', value)
      }
    },
    subFormMark(){
      return transformI18n('common.form.type.subForm', this.formPreviewLocale)
    },
    subFormPreviewTitle(){
      return transformI18n('common.base.concatField', this.formPreviewLocale)
    }
  }
}
</script>
<style lang="scss" scoped>
@import '@src/component/form/components/FormSubForm/FormSubForm.scss';
::v-deep .form-preview-group {
  line-height: normal;
}
.sub-preview-empty-show {
  min-height: 62px;
  padding: 8px 12px 12px;
  background: none;
}
::v-deep .form-design-preview-disabled {
  border-color: #F0F0F0 !important;
}
</style>